package org.example.meitiguanli.controller;

import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import org.example.core.controller.BaseController;
import org.example.core.enums.ApiResult;
import org.example.core.mysql.SearchPageResult;
import org.example.meitiguanli.model.TInformationModel;
import org.example.meitiguanli.service.TInformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * Description:
 * Date: 2024/2/16 20:38
 */
@RestController
@RequestMapping("/information")
public class TInformationController extends BaseController<String, TInformationService, TInformationModel> {

    @Autowired
    private TInformationService tInformationService;

    /**
     * 提交
     * @param params
     * @return
     */
    @PostMapping("/submitInformation")
    public ApiResult submitInformation(@RequestBody Map<String,Object> params){
        tInformationService.submitInformation(params);
        return ApiResult.success();
    }
    /**
     * 1：通过/2：不通过
     * @param params
     * @return
     */
    @PostMapping("/updateStatus")
    public ApiResult updateStatus(@RequestBody Map<String,Object> params){
        tInformationService.updateStatus(params);
        return ApiResult.success();
    }

    /**
     * 分页查询
     * @param params
     * @param page
     * @param limit
     * @return
     */
    @GetMapping("/searchList")
    public ApiResult searchList(@RequestParam(required = false) Map<String,Object> params,
                                @RequestParam int page,
                                @RequestParam int limit){
        SearchPageResult<JSONObject> result = tInformationService.searchList(params,page,limit);
        return ApiResult.success(result);
    }
}
